<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = ["twj", "tiechui", "gangdan"]
        console.log(arr[0]) //twj
        console.log(arr[arr.length - 1]) //tiechui
        console.log(arr[arr.length - 2]) //gangdan
        console.log(arr.at(0)) //twj
        console.log(arr.at(-1)) //tiechui
        console.log(arr.at(-2)) //gangdan
        //在字符串中也适用

        let str = "今天是2023-04-12"
        let reg = /(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})/d
        let res = reg.exec(str)
        console.log(res)
        //加上d，返回结果就会封装一个indices属性，属性里面就是每次匹配的结果的索引开始和结束索引
    </script>
</body>

</html>